package com.huawei.appgallery.foundation.ui.css.adapter;

import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import com.huawei.appgallery.foundation.ui.css.adapter.type.factory.CSSValueFactory;
import java.util.HashMap;
import java.util.Map;

public class CSSValueDecoder {
    private static final String TAG = "CSSValueDecoder";
    private static CSSValueDecoder instance = new CSSValueDecoder();
    Map<String, CSSValueFactory> map = new HashMap();

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private CSSValueDecoder() {
        /*
        r9 = this;
        r9.<init>();
        r0 = new java.util.HashMap;
        r0.<init>();
        r9.map = r0;
        r0 = com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName.class;
        r3 = r0.getFields();
        r4 = r3.length;
        r0 = 0;
        r2 = r0;
    L_0x0013:
        if (r2 >= r4) goto L_0x006c;
    L_0x0015:
        r5 = r3[r2];
        r0 = com.huawei.appgallery.foundation.ui.css.annotation.ValueFactory.class;
        r0 = r5.isAnnotationPresent(r0);
        if (r0 == 0) goto L_0x003f;
    L_0x001f:
        r1 = "";
        r0 = 0;
        r0 = r5.get(r0);	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x004c }
        r0 = (java.lang.String) r0;	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x004c }
        r1 = com.huawei.appgallery.foundation.ui.css.annotation.ValueFactory.class;
        r1 = r5.getAnnotation(r1);	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r1 = (com.huawei.appgallery.foundation.ui.css.annotation.ValueFactory) r1;	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r1 = r1.value();	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r1 = r1.newInstance();	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r1 = (com.huawei.appgallery.foundation.ui.css.adapter.type.factory.CSSValueFactory) r1;	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r5 = r9.map;	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
        r5.put(r0, r1);	 Catch:{ IllegalAccessException -> 0x0043, InstantiationException -> 0x006d }
    L_0x003f:
        r0 = r2 + 1;
        r2 = r0;
        goto L_0x0013;
    L_0x0043:
        r0 = move-exception;
        r0 = "CSSValueDecoder";
        r1 = "get property name failed!";
        android.util.Log.e(r0, r1);
        goto L_0x003f;
    L_0x004c:
        r0 = move-exception;
    L_0x004d:
        r5 = "CSSValueDecoder";
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r7 = "Instancing property ";
        r6 = r6.append(r7);
        r1 = r6.append(r1);
        r6 = " value's factory failed!";
        r1 = r1.append(r6);
        r1 = r1.toString();
        android.util.Log.e(r5, r1, r0);
        goto L_0x003f;
    L_0x006c:
        return;
    L_0x006d:
        r1 = move-exception;
        r8 = r1;
        r1 = r0;
        r0 = r8;
        goto L_0x004d;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.appgallery.foundation.ui.css.adapter.CSSValueDecoder.<init>():void");
    }

    public static CSSValueDecoder getInstance() {
        return instance;
    }

    public CSSValue decode(String str, String str2) {
        CSSValueFactory cSSValueFactory = (CSSValueFactory) this.map.get(str);
        if (cSSValueFactory != null) {
            return cSSValueFactory.create(str2);
        }
        return null;
    }
}
